using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Tao.OpenGl;

namespace TaoOpenGLTest
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private float xRot = 0.0f;
        private float yRot = 0.0f;
        private float zRot = 0.0f;
        
        private void simpleOpenGlControl1_Load(object sender, EventArgs e)
        {
            simpleOpenGlControl1.InitializeContexts();
        }

        private void simpleOpenGlControl1_Paint(object sender, System.Windows.Forms.PaintEventArgs e)
        {
            Gl.glClear(Gl.GL_COLOR_BUFFER_BIT | Gl.GL_DEPTH_BUFFER_BIT);
            Gl.glLoadIdentity();
            Gl.glTranslatef(0.0f, 0.25f, 0.0f);
            Gl.glRotatef((xRot+yRot+zRot)%360, xRot, yRot, zRot);
            Gl.glScalef(0.5f, 1.5f, 0f);
            
            drawTriangle();
        }

        private void drawTriangle()
        {
            Gl.glBegin(Gl.GL_TRIANGLES);
            Gl.glVertex3f(-0.5f, -0.5f, 0.0f);
            Gl.glVertex3f(0.5f, -0.5f, 0.0f);
            Gl.glVertex3f(0.0f, 0.5f, 0.0f);
            Gl.glEnd();
        }

        private void xTrackBar_Scroll(object sender, EventArgs e)
        {
            xRot = (float)xTrackBar.Value;
            this.Refresh();
        }

        private void yTrackBar_Scroll(object sender, EventArgs e)
        {
            yRot = (float)yTrackBar.Value;
            this.Refresh();
        }

        private void zTrackBar_Scroll(object sender, EventArgs e)
        {
            zRot = (float)zTrackBar.Value;
            this.Refresh();
        }




    }
}